<div class="gap"></div>

<section class="form-step1">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">Update College Information</h3>
                    </div>
                    <div class="panel-body">
                        <?php
                        $form = $this->beginWidget('GxActiveForm', array(
                            'id' => 'checkPassword',
                            'enableAjaxValidation' => false,
                            'htmlOptions' => array('class' => 'form-horizontal')
                        ));
                        ?>               

                        <div class="form-group">                   
                            <label class="col-sm-5 control-label" for="">Do you have a Login Password ? </label>
                            <div class="col-sm-3">
                                <label class="radio-inline">
                                    <input type="radio" class="inlineradio2" name="radio" id="yespassword" placeholder="Password">Yes
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" class="inlineradio3" name="radio" id="Nopassword" placeholder="Password">No
                                </label>
                            </div>

                        </div>
                        <div class="passwordYes" style="display: none;">
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-5 control-label">Type password<span class="red">*</span>: </label>
                                <div class="col-sm-3"> <input type="password" class="form-control" id="" placeholder="Password" name="password" onkeypress="return (event.keyCode != 13)"><br>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label" for="">&nbsp; </label>                            
                                <button type="button" class="submit1" onclick="checkPassword()">Submit</button>
                                <span class="errorMessage" id="errorPassword"></span>
                            </div>

                        </div>
                        <span class="errorMessage" id="sendMail"></span>
                        <div class="PasswordNo" style="display: none;">                        
                            <h3 >Details Of Head Of Institute:</h3>
                            <div class="gap"></div>
                            <div class="form-group">
                                <div class="col-sm-3 control-label"><?php echo $form->labelEx($model, 'hod_title'); ?>
                                </div>
                                <div class="col-sm-4">           
                                    <?php echo $form->textField($model, 'hod_title', array('maxlength' => 105, 'class' => 'form-control')); ?>
                                    <?php echo $form->error($model, 'hod_title'); ?>
                                </div><!-- row -->
                            </div>
                            <div class="clearfix"></div>
                            <div class="clearfix"></div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <div class="col-sm-3 control-label"><?php echo $form->labelEx($model, 'hod_first_name'); ?>
                                </div>
                                <div class="col-sm-4"><?php echo $form->textField($model, 'hod_first_name', array('maxlength' => 105, 'class' => 'form-control')); ?>
                                    <?php echo $form->error($model, 'hod_first_name'); ?>
                                </div><!-- row -->
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <div class="col-sm-3 control-label"><?php echo $form->labelEx($model, 'hod_last_name'); ?>
                                </div>
                                <div class="col-sm-4"><?php echo $form->textField($model, 'hod_last_name', array('maxlength' => 105, 'class' => 'form-control')); ?>
                                    <?php echo $form->error($model, 'hod_last_name'); ?>
                                </div><!-- row -->
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <div class="col-sm-3 control-label"><?php echo $form->labelEx($model, 'designation'); ?>
                                </div>
                                <div class="col-sm-4"><?php echo $form->textField($model, 'designation', array('maxlength' => 105, 'class' => 'form-control')); ?>
                                    <?php echo $form->error($model, 'designation'); ?>
                                </div><!-- row -->
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <div class="col-sm-3 control-label"><?php echo $form->labelEx($model, 'hod_email'); ?>
                                </div>
                                <div class="col-sm-4"><?php echo $form->textField($model, 'hod_email', array('maxlength' => 105, 'class' => 'form-control')); ?>
                                    <?php echo $form->error($model, 'hod_email'); ?>
                                </div><!-- row -->
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <div class="col-sm-3 control-label"><?php echo $form->labelEx($model, 'hod_mobile_number'); ?>
                                </div>
                                <div class="col-sm-4">
                                    <div class="input-group">
                                        <span class="input-group-addon">+91</span>
                                        <?php echo $form->textField($model, 'hod_mobile_number', array('maxlength' => 105, 'class' => 'form-control')); ?>
                                    </div>
                                    <?php echo $form->error($model, 'hod_mobile_number'); ?>
                                </div><!-- row -->
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label" for="">&nbsp; </label>                            
                                <button type="button" class="submit1" onclick="sendmail()">Send Mail</button>

                            </div>
                        </div>



                        <?php
                        $this->endWidget();
                        ?>
                        </section>
                        <div class="gap"></div>
                        <div class="gap"></div>  
                        <script>
                            $(document).ready(function() {
                                $('input:radio').change(function() {
                                    if ($(this).attr('id') == 'yespassword') {
                                        $(".PasswordNo").hide();
                                        $("#sendMail").hide();
                                        $(".passwordYes").show();

                                    } else {
                                        $("#sendMail").hide();
                                        $(".passwordYes").hide();
                                        $(".PasswordNo").show();
                                    }
                                });
                            })
                            function checkPassword() {
                                $.ajax({
                                    url: "<?php echo CController::createUrl('collegeDetails/checkPassword') ?>",
                                    type: "POST",
                                    data: $("#checkPassword").serialize(),
                                    success: function(data, textStatus, jqXHR) {
                                        if (data == 1) {
                                            window.location.href = '<?php echo CController::createUrl('collegeDetails/CollgeInfoUpdate') ?>';
                                        } else {
                                            $("#errorPassword").html(data);
                                        }
                                    },
                                });
                            }

                            function sendmail() {
                                $.ajax({
                                    url: "<?php echo CController::createUrl('collegeDetails/UpdateCollgeInfor') ?>",
                                    type: "POST",
                                    data: $("#checkPassword").serialize(),
                                    success: function(data, textStatus, jqXHR) {
                                        $("#sendMail").show();
                                        $("#sendMail").html(data);
                                        $(".PasswordNo").hide();

                                    },
                                });
                            }

                        </script>